import { useEffect, useState } from "react";
import { getBreadcRumb, push } from "@/utils/util";
import ListForm from '@/components/ListForm'
import { useLocation, useParams } from "react-router";
import { save, update, detail } from "@/apis/tenant";
import { message } from "antd";
interface onFinishValue extends TenantSaveParam {
    time: string | number[]
    city: AreaVO[]
}
function Common() {
    const params = useParams()
    const [values, setvalues] = useState<any>()
    getBreadcRumb([{ name: '通用设置' }])
    const list: listItem[] = [
        {
            name: "tenantName",
            label: "普通陪玩抽成",
            type: "inputNumber",
            min: 0,
            max: 100,
            formatter: value => `${value}%`,
            rules: [{ required: true, message: '请输入抽成名称' }],
        },
    ]
    //确定调接口
    async function onFinish(values: onFinishValue) {
        await update({ ...values, id: params.id })
        message.success('编辑成功')
    }
    async function init() {
        if (params.id) {
            let res = await detail({ id: params.id })
            setvalues({ ...res.data })
        }
    }
    useEffect(() => {
        init()
    }, [])
    return (
        <div className='tableWrap'>
            <h2>通用设置</h2>
            <ListForm list={list} values={values} onFinish={onFinish}></ListForm>
        </div>
    )
}

export default Common;